home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Svd Messageboard Arcive / ephemeric / data / MBPREP.ZIP / TRE2MSG.PHP < prev    next >
Encoding:
Text File  |  1999-10-16  |  4.0 KB  |  95 lines

  1. <HTML>
  2. <HEAD><TITLE><? echo $TITLE > -- online library</TITLE></HEAD>
  3. <BODY TEXT="#000000" BGCOLOR="#c0c0c0" LINK="#0000E0" VLINK="#00E000" ALINK="#E00000" >
  4. <center><? echo "<b>$TITLE</b> -- <a href=\"$URL\">$URL" > </A> rebuilt <BR>
  5.  
  6. <!-- Generated by TREe2MSGbrd.PHP;
  7. <? echo "$IN, lines-per-page=$PERPAGE; pageprefix=$PAGENAME" > -->
  8.  
  9. <?
  10.  /* pages count from 1; $perpage<=0 or $pageno<=0 means All */
  11.  /* cuts ONLY at whole threads */
  12. /*Function tre2msgb ();*/
  13.  
  14. /* global $PERPAGE,$IN,$PAGENAME;*/
  15.  $pageno = intval(ereg_replace( "(.*/)*"+$PAGENAME, "", $PATH_DIR));    /* .../x/y/pagename34... = no.34 */
  16. #$pageno = 1; $IN="MB155985.TRE";
  17. #$PERPAGE = 50;
  18.  $fromline = 0; $toline = 0;
  19.  echo "page $pageno; (about $PERPAGE posts per page); ";
  20.  if ($pageno>0 && $PERPAGE>0) {
  21.    if ($pageno>1) { echo "<a href=\"$PAGENAME", sprintf("%02d",$pageno-1), ".HTM\">prev</a>; "; }
  22.    echo "<a href=\"$PAGENAME", sprintf("%02d", $pageno+1), ".HTM\">next</a>";
  23.    $toline = $pageno * $PERPAGE; $fromline = $toline - $PERPAGE;
  24.   }
  25.  echo "</center><BR><hr>\n";
  26.  
  27.  if (fileSize($IN) <=0) { echo "sorry - file not found $IN"; exit; }
  28.  $h = fopen( $IN, "r");                /* fails if not found! */
  29.  if ($h==-1) { echo "sorry"; exit; }
  30.  $lvlprev=0; $lvl=0; $missing=0; $lines=0; $threads=0; $herelines=0;
  31.  $on=0; $getout=0;
  32.  while (!feof($h) && !$getout) {        /*oh, no break nor continue :( */
  33.   $lines++;
  34.   $lvl = intval(fgets($h,20)); /* string is always non-zero, so make it number */
  35.   $mail=fgets($h,200); $name=fgets($h,200);
  36.   $mssg=fgets($h,30); $subj=fgets($h,512); $date=fgets($h,50);
  37.   /*  fgets($h,20); */   /* one empty line!*/
  38.   if (!$lvl && $lines>=$fromline) {     /*main msg only*/
  39.     $on=1; if ($toline > 0 && $lines > $toline) { $getout=1; $on=0; }
  40.   }
  41.  
  42.   if ($on) { $herelines++;
  43.     $i=$lvl; while ($i<$lvlprev) { echo "</ul>"; $i++; }
  44.     $i=$lvlprev; while ($i<$lvl) { echo "<ul>"; $i++; }
  45.     if (!$lvl) { $threads++; echo "\n<hr>"; }
  46.  
  47.     $m = strlen($mail);
  48.     if ($m>1) { $mail=substr($mail,0,$m-1); echo "<A HREF=\"mailto:$mail\">"; }
  49.     echo $name; if ($m>1) { echo "</A>"; }
  50.     echo ": ";
  51.  
  52.     $mss9= substr($mssg,0,2)+"/"+substr($mssg,0,strlen($mssg)-1); /* $autoprefix */
  53.     $mssg = ereg_replace( "\.9$", "\.HTM", $mss9);   /*files named *.9 are NOT recognised as HTML. why?*/
  54. /*   $missing = 0;       does not work?!
  55.      if ((fileType($mssg) == -1) && (fileType($mss9) == -1)) { $missing++; }
  56. /*   $dup=0; if ($msgprev==$mssg) { $dup++; }
  57.      $msgprev = $mssg;
  58.     if ($dup) { echo "dup: "; }
  59.     if ($disable_missing_links && !$missing) { echo "OK: "; }
  60. */
  61.     if (!$missing) { echo "<A HREF=\"$mssg\">"; }
  62.      else { echo "missing($mssg or .9): "; }
  63.     if (!$lvl) { echo "<B>"; } echo $subj; if (!$lvl) { echo "</B>"; }
  64.     if (!$missing) { echo "</A>"; }
  65.     echo " $date<BR>\r\n";
  66.     $lvlprev = $lvl;
  67.    }
  68.   }
  69.  fclose($h);
  70.  while ($lvlprev>0) { echo "</ul>"; $lvlprev--; }
  71.  echo "<BR><BR>----------- eo page ";
  72.  if ($pageno>0 && $PERPAGE>0) { echo $pageno; }
  73.  if (!$getout) { echo "; ----- eo archive"; }
  74. /*); /*eo func*/
  75.  
  76. /*not strtok nor regexps understand from \f, \r, \b, \xXX or any escaped things.
  77.   so, replace them with new line and read 6 lines :(
  78.   newline is included in the string from fgets! so do substr(sz-1)  :(
  79. -no such function
  80.   $l=strtr($l,"\f","~");
  81. -does not work
  82.   ereg( "^([^\f]*)\f([^\f]*)\f([^\f]*)\f([^\f]*)\f([^\f]*)\f([^\f]*)",$l, $regs);
  83.   $lvl=0+$regs[1]; $mail=$regs[2]; $name=$regs[3]; $mssg=$regs[4]; $subj=$regs[5]; $date=$regs[6];
  84. -does not work
  85.   $l = ereg_replace( "\f", " \f", $l); $lvl = 0+strtok($l, "\f"); $mail= strtok("\f"); $name= strtok("\f"); $mssg= strtok("\f"); $subj= strtok("\f"); $date= strtok("\f");
  86.  and there's no ?: operator, and ..., and, ...
  87.  well, this php2 is crap - almost every line here is a workaround
  88. -don't use fuctions for big things, they eat too mauch space
  89. */
  90. >
  91. <!-- Generated by TREe2MSGbrd.PHP;
  92. <? echo "page $pageno; threads=$threads; lines=$fromline-$toline ($herelines)" >
  93. SvD Jul'99 -->
  94. </BODY></HTML>
  95.